//
//  eventAction.m
//  GBKHOME
//
//  Created by Fly on 2017/9/18.
//
//

#import "eventAction.h"
#import "WebServices.h"

@implementation eventAction

+(void)electricCompantWithOrder:(BOOL)bSwitch swtichId:(NSString *)switchID result:(void(^)(NSDictionary *dic))result{
    NSString *order = @"";
    if(!bSwitch)
    {
        order = @"CLOSE";
    } else {
        order = @"OPEN";
    }
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchID, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlDevice" body:body result:^(NSDictionary *dic) {
        if (result) {
            result(dic);
        };
    }];
}

+(void)electricAllCompantWithOrder:(BOOL)bSwitch swtichId:(NSString *)switchID result:(void(^)(NSDictionary *dic))result{
    NSString *order = @"";
    if(!bSwitch)
    {
        order = @"ALLCLOSE";
    } else {
        order = @"ALLOPEN";
    }
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchID, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlDevice" body:body result:^(NSDictionary *dic) {
        if (result) {
            result(dic);
        };
    }];
}

+(void)electricCurtainsWithOrder:(BOOL)bSwitch swtichId:(NSString *)switchID result:(void(^)(NSDictionary *dic))result{
    NSString *orderName = NSLocalizedString(@"pause", nil);
    NSString *operat = NSLocalizedString(@"operat:", nil);
    NSString *startTip = [operat stringByAppendingString:orderName];
    [iToast showTip:startTip gravity:iToastGravityBottom];
    
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, switchID, sessionId];
    
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"stopPurdah" body:body result:^(NSDictionary *dic) {
        if (result) {
            result(dic);
        };
    }];
}

+ (void)airconditionCtrlWithOrder:(NSString *)order switchId:(NSString *)switchID result:(void(^)(NSDictionary *dic))result{
    NSString *switchId = switchID;
    
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchId, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlAC" body:body result:^(NSDictionary *dic) {
        if (result) {
            result(dic);
        };
    }];
}

@end
